<?php 

require_once('getconfig.php');

Class Model_membermaster extends Dbo_DbManager
 {
	protected $pn_id;	
	protected $c_username;
	protected $c_password;
	protected $c_first_name;
	protected $c_district;
	protected $c_state;
	protected $c_details;
	protected $c_address;
	protected $c_pin;
	protected $c_email;
	protected $ref_id;
	protected $c_status;
	protected $d_join;
	protected $c_typ_Business;
	protected $c_business_subfield;
	

    public function __construct($createCon=TRUE){
 	  parent::__construct($createCon);
 	}
	
	public function getuserid()
	{
		return  $this->pn_id;
	}
	public function getUsername()
	{
		return  $this->c_username;
	}	
	public function getPassword()
	{
		return  $this->c_password;
	}				
	public function getFirstname()
	{
		return  $this->c_first_name;
	}	

	public function getCountry()
	{
		return  $this->c_district;
	}				
	public function getDetails()
	{
		return  $this->c_details;
	}
	public function getState()
	{
		return  $this->c_state;
	}					
	public function getAddress()
	{
		return  $this->c_address;
	}	
	public function getPincode()
	{
		return  $this->c_pin;
	}	
	public function getEmail()
	{
		return  $this->c_email;
	}	
	public function getIama()
	{
		return  $this->ref_id;
	}	
	public function getMobileno()
	{
		return  $this->c_mobil;
	}		
	public function getDjoin()
	{
		return  $this->d_join;
	}
	public function getCstatus()
	{
		return  $this->c_status;
	}	
	public function getBusinesstype()
	{
		return  $this->c_typ_Business;
	}			
	public function getBusinesssubfield()
	{
		return  $this->c_business_subfield;
	}
//--------seting-------
	public function setuserid($pn_id)
	{
		$this->pn_id=$pn_id;
	}
	public function setUsername($c_username)
	{
		$this->c_username=$c_username;
	}
	public function setPassword($c_password)
	{
		$this->c_password=$c_password;
	}
	public function setFirstname($c_first_name)
	{
		$this->c_first_name=$c_first_name;
	}		
 	public function setBusinesstype($c_typ_Business)
	{
		$this->c_typ_Business=$c_typ_Business;
	}	
	public function setCountry($c_district)
	{
		$this->c_district=$c_district;
	}
	public function setDetails($c_details)
	{
		$this->c_details=$c_details;
	}
	public function setState($c_state)
	{
		$this->c_state=$c_state;
	}
	public function setAddress($c_address)
	{
		$this->c_address=$c_address;
	}		
	public function setPincode($c_pin)
	{
		$this->c_pin=$c_pin;
	}
	public function setEmail($c_email)
	{
		$this->c_email=$c_email;
	}		
	public function setIama($ref_id)
	{
		$this->ref_id=$ref_id;
	}	
	public function setDjoin($d_join)
	{
		$this->d_join=$d_join;
	}	
	public function setMobileno($c_mobil)
	{
		$this->c_mobil=$c_mobil;
	}				
	public function setCstatus($c_status)
	{
		$this->c_status=$c_status;
	}	
	public function setBusinesssubfield($c_business_subfield)
	{
		$this->c_business_subfield=$c_business_subfield;
	}			

//---------------------------------------------------------//	
	public function write()
	{
		$objDbManager = new Dbo_DbManager();
		return $objDbManager->write($this,FALSE);
	}
	public static function delete($intuserid)
	{
		$objDbManager = new Dbo_DbManager();
		return $objDbManager->remove($intuserid,__CLASS__);
	}


	public static function get($intuserid=NULL)
	{
		$arrRes=array();
		$objDbManager = new Dbo_DbManager();
		$arrModel_Membermaster = $objDbManager->fetch(array('intuserid' => $intuserid),__CLASS__);
		if(count($arrModel_Membermaster)>0) {
			foreach($arrModel_Membermaster as $arrNew) { 
				$objUser = self::build($arrNew);
				$arrRes[]=$objUser;
			}
		}
		return $arrRes;
	}


	public function getoncondition()
	{
		$arrRes=array();
		$objDbManager = new Dbo_DbManager();
		$arrModel_Membermaster = $objDbManager->fetchOnCondition($this,TRUE);
		if(count($arrModel_Membermaster)>0) {
			foreach($arrModel_Membermaster as $arrNew) { 
				$objUser = self::build($arrNew);
				$arrRes[]=$objUser;
			}
		}
		return $arrRes;
	}


	public static function build(array $arrModel_Membermaster)
	{
		$objModel_Membermaster = new Model_Membermaster(FALSE);
		@$objModel_Membermaster->setuserid($arrModel_Membermaster['pn_id']);
		@$objModel_Membermaster->setUsername($arrModel_Membermaster['c_username']);
		@$objModel_Membermaster->setPassword($arrModel_Membermaster['c_password']);
		@$objModel_Membermaster->setFirstname($arrModel_Membermaster['c_first_name']);
		@$objModel_Membermaster->setCountry($arrModel_Membermaster['c_district']);
		@$objModel_Membermaster->setState($arrModel_Membermaster['c_state']);
		@$objModel_Membermaster->setDetails($arrModel_Membermaster['c_details']);
		@$objModel_Membermaster->setAddress($arrModel_Membermaster['c_address']);
		@$objModel_Membermaster->setPincode($arrModel_Membermaster['c_pin']);
		@$objModel_Membermaster->setEmail($arrModel_Membermaster['c_email']);
		@$objModel_Membermaster->setMobileno($arrModel_Membermaster['c_mobil']);
		@$objModel_Membermaster->setIama($arrModel_Membermaster['ref_id']);
		@$objModel_Membermaster->setCstatus($arrModel_Membermaster['c_status']);
		@$objModel_Membermaster->setDjoin($arrModel_Membermaster['d_join']);	
		@$objModel_Membermaster->setBusinesstype($arrModel_Membermaster['c_typ_Business']);
		@$objModel_Membermaster->setBusinesssubfield($arrModel_Membermaster['c_business_subfield']);
			
		return $objModel_Membermaster;
 	 }
	 
     public function getlastinsertedid(){
		$objDbManager = new Dbo_DbManager ();
		$userid=$objDbManager->getMaxId($this,"max","intuserid");
		return $userid;
	}	
	
	public static function get_member_list(){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from membermaster order by pn_id";
		
		$arrModel_Membermaster=$objDbManager->runquery("$qry");
		if (count( $arrModel_Membermaster ) > 0) {
			foreach ( $arrModel_Membermaster as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}		
	
	public static function get_search_list($State,$Dist,$Typeofbusiness,$Businesssublist)
	{
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from membermaster where c_state='$State' and c_district='$Dist' and c_typ_Business='$Typeofbusiness' and c_business_subfield='$Businesssublist' ";
		
		$arrModel_Membermaster=$objDbManager->runquery("$qry");
		if (count( $arrModel_Membermaster ) > 0) {
			foreach ( $arrModel_Membermaster as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}	
	public static function get_search_list_limit($State,$Dist,$Typeofbusiness,$Businesssublist,$start,$per_page)
	{
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
	echo	$qry="select * from membermaster where c_state='$State' and c_district='$Dist' and c_typ_Business='$Typeofbusiness' and c_business_subfield='$Businesssublist' order by pn_id limit $start,$per_page";
		
		$arrModel_Membermaster=$objDbManager->runquery("$qry");
		if (count( $arrModel_Membermaster ) > 0) {
			foreach ( $arrModel_Membermaster as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}			
			
	public static function get_member_details($propid){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from membermaster where pn_id='$propid' ";
		
		$arrModel_Membermaster=$objDbManager->runquery("$qry");
		if (count( $arrModel_Membermaster ) > 0) {
			foreach ( $arrModel_Membermaster as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}	
	
	public static function checkUser($strusername,$strpassword){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select pn_id,c_username,c_first_name,c_typ_Business from membermaster where c_username='$strusername' and c_password='$strpassword'";
		$arrModel_Memberlogin=$objDbManager->runquery("$qry");
		if (count( $arrModel_Memberlogin ) > 0) {
			foreach ( $arrModel_Memberlogin as $arrNew ) {
				$objUser = self::build ( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}
	public static function checkUserexist($strusername){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from membermaster where c_username='$strusername'";
		$arrModel_Memberlogin=$objDbManager->runquery("$qry");
		if (count( $arrModel_Memberlogin ) > 0) {
			foreach ( $arrModel_Memberlogin as $arrNew ) {
				$objUser = self::build ( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}	

	
	public static function getreguserslimit($lowerlimit,$upperlimit){
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="select * from tbluser where intuserid>1 LIMIT $lowerlimit,$upperlimit";
		$arrModel_Membermaster=$objDbManager->ExecuteQuery("$qry");
		if (count( $arrModel_Membermaster ) > 0) {
			foreach ( $arrModel_Membermaster as $arrNew ) {
				$objUser = self::build_Membermaster_bclogin ( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}
	
    public  function __call($method, $arguments) {
    	
       if(count($arguments)>0){
       	   $sqlFunction=$arguments[0];
       	    $objDbManager = new Dbo_DbManager();
       	   return $objDbManager->runSqlFunctions(__CLASS__,array($method=>$sqlFunction));
       }
    }
 
	

 }
 ?>
